package cn.plushine.service;

import cn.plushine.mapper.BaseOutputMapper;
import cn.plushine.pojo.SOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;


/**
 * 出库订单接口实现类
 */
@Service
public class BaseOutputServiceImpl implements BaseOutputService {

    @Autowired
    BaseOutputMapper baseOutputMapper;

    // 获取出库订单
    @Override
    public List<SOrder> get() {
        return baseOutputMapper.get();
    }

    @Override
    public int update(ArrayList<HashMap> multiplySelect) throws Exception {
        int updateDB = baseOutputMapper.update(multiplySelect);
        if (updateDB != 0) {
            return updateDB;
        }
        throw new Exception("批量出库失败！");
    }

    // 修改订单信息（销售订单+仓库订单）
    @Override
    public int modify(String outputId, int keeper) throws Exception {
        int modifyDB = baseOutputMapper.modify(outputId, new Date(), keeper);
        if (modifyDB != 0) {
            return modifyDB;
        }
        throw new Exception("修改订单信息（销售订单+仓库订单）失败！");
    }
}
